<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div class="title">苹果/10元一斤,(折扣8折)</div>
        <div class="num">
            请输入你想购买的斤数:<input type="text" v-model="num"></input>
        </div>
        <div class="total">价格:{{total}}元</div>
        <div class="discount">折后价:{{discount}}元</div>
        <div class="shengqian">省了:{{shengqian }}元</div>
    </div>


    <script src="./vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                num: 0,
                price: 10,
                
            },
            computed : {
                total () {
                    return this.num * this.price
                },
                discount () {
                    return this.num * this.price * 0.8
                },
                shengqian () {
                    return this.num * this.price * 0.2
                },
            }
        })


    </script>
    
</body>
</html>